package com.maxuxu.scihome.controller.mail;

import com.maxuxu.scihome.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * @className: SendEmailController
 * @author: Maxuxu
 * @date: 2022/7/6 13:22
 * @description:
 */
@Controller
// @Async
public class SendEmailController {
    @Autowired
    MailService mailService;
    @PostMapping("/sendEmail")
    @ResponseBody
    public String send(String emailName,String title,String contents){
        mailService.sendMail("870839344@qq.com",emailName,title,contents);
        return "邮件成功发送给:【"+emailName+"】,发送时间是：【"+new Date()+"】";
    }
    @GetMapping("/sendEmail")
    public String getemail(){
        return "sendEmail";
    }
}
